﻿using sMES_Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using sMES_Base.service;
using ic_card_info_get.ORM;

namespace ic_card_info_get
{
    /// <summary>
	/// 元件[ic_card_info_get]
    /// <auth>Administrator</auth><time>2020/7/2 13:44:51</time>
    /// <description></description>
    /// <list>
    ///     <modify>
    ///         <auth></auth><mantis></mantis><time></time>
    ///         <description></description>
    ///     </modify>
    /// </list>
    /// </summary>
    public class ic_card_info_get_utility : BaseUtility
    {
        public ic_card_info_get_utility(ref BaseService CurrentService) : base(ref CurrentService)
        {
        }

        public ORM_TblUsrUserBasis GetUserInfo(string icCard)
        {
            string sql = " SELECT USERNO,UserName,UserLevel,PassWord,IssueState,C_ICCardPwd FROM TBLUSRUSERBASIS WHERE IssueState=2 AND ICCard=? ";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("ICCard", icCard);
            var dao = CurrentService.GetDao();
            ORM_TblUsrUserBasis orm = new ORM_TblUsrUserBasis();
            orm = dao.Query1Record<ORM_TblUsrUserBasis>(sql, parameters);
            if (orm != null)
            {
                // 启用了IC卡密码，才能转
                if (orm.C_ICCardPwd == 1)
                    orm.PassWord = UserProvider.DecodingPassword(orm.PassWord);    //密码解密
                else
                    orm.PassWord = "";
            }
            return orm;
        }
    }
}
